﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ParallelMath.Tests.Helpers
{
    static class MatrixTestHelpers
    {
        public static void AllItemsAreInRange(this double[,] matrix, double lowerBound, double upperBound)
        {
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    if(matrix[i,j]<lowerBound || matrix[i,j]>upperBound)
                        throw new AssertFailedException(string.Format("Element [{0},{1}] is not in range [{2};{3}]",i,j,lowerBound,upperBound));
                }
            }
        }

        public static void AllItemsAreInRange(this double[] array, double lowerBound, double upperBound)
        {
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] < lowerBound || array[i] > upperBound)
                    throw new AssertFailedException(string.Format("Element [{0}] is not in range [{1};{2}]", i,
                                                                  lowerBound, upperBound));
            }
        }
    }
}
